/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package zombieville.engine;

import java.awt.event.KeyEvent;
import zombieville.GUI.FundoMovelGUI;

/**
 *
 * @author -Gui-
 */
public class FundoMovel extends ItemMovel {

    public static final int DESLOCAMENTO = 3;

    public FundoMovel(int x, int y, Cenario cenarioPai) {
        super(x, y, cenarioPai);
        
    }
    
    @Override
    public void criaItemGui() {

        setItemGui(new FundoMovelGUI(this));
    }
    
    @Override
    public void age(){
        
        move();
    }

    @Override
    public void move() {

        int dx = 0;
        int dy = 0;

        if (estaPressionado(KeyEvent.VK_RIGHT) && !estaPressionado(KeyEvent.VK_LEFT) && getPosDesenho().x >= -1600) {

            dx = -DESLOCAMENTO;
        }

        if (estaPressionado(KeyEvent.VK_LEFT) && !estaPressionado(KeyEvent.VK_RIGHT) && getPosDesenho().x <= -5) {

            dx = DESLOCAMENTO;
        }

        if (getCenarioPai().getHeroi().getPosDesenho().x == 350) {
            setPosDesenho(getPosDesenho().x + dx, getPosDesenho().y + dy);
        }
    }
}
